package org.tpdata.api.cdss.AssistantDiagnosis;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import common.Data;
import common.RunCaseJson;
import common.SetUpTearDown1;
import exceptions.TestNGRetry;
import io.qameta.allure.Story;
import io.restassured.RestAssured;
import io.restassured.response.Response;
import org.apache.log4j.Logger;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import static common.TestStep.requestAndRespondBody;

public class predictlist extends SetUpTearDown1 {
    Data data = envSetUp();
    Logger log = Logger.getLogger(predictlist.class);

    @Story("辅助诊疗-预测历史")
    @Parameters({"uri"})
    @Test(retryAnalyzer = TestNGRetry.class,description = "辅助诊疗-诊断预测-点击预测记录")

    public void runCase(String uri) {
        JSONObject json = new JSONObject();

//        Map<String,String > json=new HashMap<String, String>();
        json.put("access_token", data.getAccessToken());
        json.put("authToken", data.getAccessToken());
        json.put("uniqu_no", data.getUniquNo());
        json.put("operatorId", data.getUserId());
        json.put("authUserId", data.getUserId());
        json.put("authName", data.getUserName());
        json.put("page","1" );
        json.put("size", "150");
        log.info(json.toString());

        Response response = RunCaseJson.runCase(json, "get", uri);
        String jsonStr = response.asString();
//        log.info("响应报文：" + jsonStr);

        JSONObject obj = JSON.parseObject(jsonStr);
        JSONArray contentArr = obj.getJSONArray("responseData");

        String url = RestAssured.baseURI + ":" + RestAssured.port + "/" + uri;
        requestAndRespondBody(url,json,jsonStr);

    }
}
